package cn.geckos.fml.data
{
	import cn.geckos.fml.Type;
	
	public class StackData implements IData
	{
		private var _stack:Array = new Array();
		private var _id:String;
		
		public function StackData()
		{
			
		}
		
		public function set id(id:String):void
		{
			this._id = id;
		}
		
		public function get id():String
		{
			return this._id;
		}
		
		public function set stack(stack:Array):void
		{
			this._stack = stack;
		}
		
		public function get stack():Array
		{
			return this._stack;
		}
		
		public function push(data:IData):void
		{
			stack.push(data);
		}
		
		public function getData(index:int):IData
		{
			return stack[index];
		}
		
		public function get type():String
		{
			return Type.STACK;
		}
		
		public function equals(o:Object):Boolean
		{
			if(o == this)
			{
				return true;
			}else
			{
				if(o is StackData)
				{
					var t:StackData = o as StackData;
					if(this._id == t.id)
					{
						if(this._stack.length == t.stack.length)
						{
							for(var i:int = 0;i < this._stack.length;i++)
							{
								if(!this.getData(i).equals(t.getData(i))) return false;
							}
							return true;
						}
					}
				}
			}
			return false;
		}
	}
}